<template lang="pug">
    skin(@up="up",@down="down",@yes="yes",@back="back",@duringUp="up",@duringDown="down")
        div(class="manual-inject")
            div(class="header")
                span ----手动大剂量-----

            div(class="row")
                div(class="label")
                    span(class="iconfont") &#xe62c;
                    span 开始输注:
                div(class="value")
                    control-amount(v-model="amount",:working="true",ref="ref")
                div(class="unit")
                    span u

            div(class="row")
                div(class="label")
                    span 当日已输注
                div(class="value")
                    span {{hasInfusionAmount | fixed}}
                div(class="unit")
                    span u


            div(class="row")
                div(class="label")
                    span 日总量限制
                div(class="value")
                    span {{dayLimit}}
                div(class="unit")
                    span u

</template>

<script>
import dayjs from "dayjs";
import Base from "@/mixins/BaseVue";

export default {
  mixins: [Base],
  data() {
    return {
      visible: false,
      lastInfusion: [],
      hasInfusion: false,
      plan: { amount: null },
      meal: null,
      amount: {
        value: { name: 0, value: 0 },
        min: 0,
        max: 20,
        increment: 0.1,
        no2MaxZero: true,
        no2MinOnMax: true
      },
      dayLimit: window.dose.dayLimit
    };
  },
  computed: {
    hasInfusionAmount() {
      let result = 0;
      const today = dayjs().format("YYYYMMDD");
      window.dose.records.forEach((record, index) => {
        if (dayjs(record.date).format("YYYYMMDD") == today)
          result = (result * 10 + record.amount * 10) / 10;
      });

      return result;
    }
  },
  methods: {
    up() {
      this.$refs.ref.up();
    },
    down() {
      this.$refs.ref.down();
    },

    back() {
      if (this.visible) {
        this.visible = false;
      } else {
        this.$router.push("/large-dose/menu?index=0");
      }
    },
    yes() {
      if (this.amount.value.value > 0) {
        this.$router.push("commonSure?amount=" + this.amount.value.value);
      }
    }
  }
};
</script>

<style lang="less" scoped>
.manual-inject{
    font-size: 18px;
}

.header{
    height: 26px;
    text-align: center;
}
.row {
  width: 184px;
  height: 26px;

  .label,
  .value,
  .unit {
    display: inline-block;
  }

  .label {
    width: 110px;
    padding-left: 10px
  }
  .value {
    width: 44px;
    text-align: center;
  }
  .unit {
    width: 20px;
    text-align: center;
  }
}
</style>
